﻿#region Disclaimer/Info

/////////////////////////////////////////////////////////////////////////////////////////////////
//
//   File:		Utils.cs
//   Website:		http://dexterblogengine.com/
//   Authors:		http://dexterblogengine.com/About.ashx
//   Rev:		1
//   Created:		19/01/2011
//   Last edit:		19/01/2011
//   License:		GNU Library General Public License (LGPL)
//   File:            Utils.cs
//   For updated news and information please visit http://dexterblogengine.com/
//   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
//   For any question contact info@dexterblogengine.com
//
///////////////////////////////////////////////////////////////////////////////////////////////////

#endregion

using System;
using System.Linq;
using System.Text;
using Castle.DynamicProxy;

namespace Dexter.IoC.Castle {
	internal class Utils {
		public static String CreateInvocationLogString ( IInvocation invocation ) {
			var sb = new StringBuilder ( 100 );
			sb.AppendFormat ( "Called: {0}.{1}(" , invocation.TargetType.Name , invocation.Method.Name );
			foreach ( object argument in invocation.Arguments ) {
				String argumentDescription = argument == null
				                             	? "null"
				                             	: argument.ToString ( );
				sb.Append ( argumentDescription ).Append ( "," );
			}
			if ( invocation.Arguments.Count ( ) > 0 ) {
				sb.Length--;
			}
			sb.Append ( ")" );
			return sb.ToString ( );
		}
	}
}